/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-02-24 17:26:10
 * @LastEditTime: 2024-02-24 20:19:12
 * @FilePath: /react-vite-admin/src/store/tags/index.ts
 */
import { IRoute } from "@/router/router.types";
import { makeAutoObservable } from "mobx";

class Tags {
    tagList: IRoute[] = [];
    constructor() {
        //自动观察
        makeAutoObservable(this, {}, { autoBind: true });
    }
    //添加tag标签
    addTag(route: IRoute) {
        const index = this.tagList.findIndex((item: IRoute) => item.path == route.path);
        if (index == -1) {
            this.tagList.push(route);
        }
    }
    //删除tag标签
    removeTag(route: IRoute) {
        const index = this.tagList.findIndex((item: IRoute) => item.path == route.path);
        if (index != -1) {
            this.tagList.splice(index, 1);
        }
    }
}

export default Tags;